﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using VanTaiProperty;
namespace VanTaiData
{
    public class TMCommandTransferOrder_Controller : clsConnect
    {
        private clsConnect cls = new clsConnect();
        private DataTable dt;
        #region[Get-Data]
        public DataTable BindGridTM_CommandTransferOrder()
        {
            return cls.BindGridData("sp_TM_TMCommandTransferOrder");
        }
        public DataTable BindGridTM_TMCommandTransferOrder_Detail_Edit(int id)
        {
            return cls.LayDuLieuParameter("sp_TM_TMCommandTransferOrder_Detail_Edit", "@Id", id);
        }
        public DataTable BindGridTM_Log(string keywords)
        {
            return cls.Search("sp_TM_TMCommandTransferOrder_Log", "@KEYWORDS", keywords);
        }
        #endregion

        #region[Insert-Update-Delete]
        public bool InsertTMCommandTransferOrde(clsTMCommandTransferOrderProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@DommandTransferOrder_Alias", data.DommandTransferOrder_Alias);
            cls.AddParameter("@DommandTransferOrder_Date", data.DommandTransferOrder_Date);
            cls.AddParameter("@DO_BILL_ID", data.DO_BILL_ID);
            cls.AddParameter("@Quality_DO", data.Quality_DO);
            cls.AddParameter("@Total_DO", data.Total_DO);
            cls.AddParameter("@DommandTransferOrder_Mem_ID", data.DommandTransferOrder_Mem_ID);
            cls.AddParameter("@DommandTransferOrder_Vehicle_ID", data.DommandTransferOrder_Vehicle_ID);
            cls.AddParameter("@DommandTransferOrder_Customers_ID", data.DommandTransferOrder_Customers_ID);
            cls.AddParameter("@DommandTransferOrder_Booking_Number", data.DommandTransferOrder_Booking_Number);
            cls.AddParameter("@DommandTransferOrder_Cont_Number", data.DommandTransferOrder_Cont_Number);
            cls.AddParameter("@DommandTransferOrder_Delivery_ID_0", data.DommandTransferOrder_Delivery_ID_0);
            cls.AddParameter("@DommandTransferOrder_Delivery_ID_1", data.DommandTransferOrder_Delivery_ID_1);
            cls.AddParameter("@DommandTransferOrder_Delivery_ID_2", data.DommandTransferOrder_Delivery_ID_2);
            cls.AddParameter("@DommandTransferOrder_Delivery_ID_3", data.DommandTransferOrder_Delivery_ID_3);
            cls.AddParameter("@DommandTransferOrder_Delivery_KM_Number", data.DommandTransferOrder_Delivery_KM_Number);
            cls.AddParameter("@DommandTransferOrder_Delivery_Oil_Number", data.DommandTransferOrder_Delivery_Oil_Number);
            cls.AddParameter("@DommandTransferOrder_Request", data.DommandTransferOrder_Request);
            cls.AddParameter("@DommandTransferOrder_Cont_ID", data.DommandTransferOrder_Cont_ID);
            cls.AddParameter("@DommandTransferOrder_Note", data.DommandTransferOrder_Note);
            cls.AddParameter("@DommandTransferOrder_Status_Mem", data.DommandTransferOrder_Status_Mem);
            cls.AddParameter("@DommandTransferOrder_Leadership", data.DommandTransferOrder_Leadership);
            cls.AddParameter("@DommandTransferOrder_Level_1", data.DommandTransferOrder_Level_1);
            cls.AddParameter("@DommandTransferOrder_Level_2", data.DommandTransferOrder_Level_2);
            cls.ExecuteNonQuery("sp_TM_TMCommandTransferOrder_Insert");
            return true;
        }
        public bool UpdateTMCommandTransferOrde(clsTMCommandTransferOrderProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@DommandTransferOrder_ID", data.DommandTransferOrder_ID);
            cls.AddParameter("@DommandTransferOrder_Alias", data.DommandTransferOrder_Alias);
            cls.AddParameter("@DommandTransferOrder_Date", data.DommandTransferOrder_Date);
            cls.AddParameter("@DommandTransferOrder_Mem_ID", data.DommandTransferOrder_Mem_ID);
            cls.AddParameter("@DommandTransferOrder_Vehicle_ID", data.DommandTransferOrder_Vehicle_ID);
            cls.AddParameter("@DommandTransferOrder_Customers_ID", data.DommandTransferOrder_Customers_ID);
            cls.AddParameter("@DommandTransferOrder_Booking_Number", data.DommandTransferOrder_Booking_Number);
            cls.AddParameter("@DommandTransferOrder_Cont_Number", data.DommandTransferOrder_Cont_Number);
            cls.AddParameter("@DommandTransferOrder_Delivery_ID_0", data.DommandTransferOrder_Delivery_ID_0);
            cls.AddParameter("@DommandTransferOrder_Delivery_ID_1", data.DommandTransferOrder_Delivery_ID_1);
            cls.AddParameter("@DommandTransferOrder_Delivery_ID_2", data.DommandTransferOrder_Delivery_ID_2);
            cls.AddParameter("@DommandTransferOrder_Delivery_ID_3", data.DommandTransferOrder_Delivery_ID_3);
            cls.AddParameter("@DommandTransferOrder_Delivery_KM_Number", data.DommandTransferOrder_Delivery_KM_Number);
            cls.AddParameter("@DommandTransferOrder_Delivery_Oil_Number", data.DommandTransferOrder_Delivery_Oil_Number);
            cls.AddParameter("@DommandTransferOrder_Request", data.DommandTransferOrder_Request);
            cls.AddParameter("@DommandTransferOrder_Cont_ID", data.DommandTransferOrder_Cont_ID);
            cls.AddParameter("@DommandTransferOrder_Note", data.DommandTransferOrder_Note);
            cls.AddParameter("@DommandTransferOrder_Status_Mem", data.DommandTransferOrder_Status_Mem);
            cls.AddParameter("@DommandTransferOrder_Leadership", data.DommandTransferOrder_Leadership);
            cls.AddParameter("@DommandTransferOrder_Level_1", data.DommandTransferOrder_Level_1);
            cls.AddParameter("@DommandTransferOrder_Level_2", data.DommandTransferOrder_Level_2);
            cls.ExecuteNonQuery("sp_TM_TMCommandTransferOrder_Update");
            return true;
        }
        public bool InsertSaleReport(clsTMCommandTransferOrderProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Id", data.DommandTransferOrder_ID);
            cls.ExecuteNonQuery("sp_sp_TMSalesReport_Insert");
            return true;
        }
        public bool DeleteTMCommandTransferOrder(int id)
        {
            cls.Delete("sp_TM_TMCommandTransferOrder_Delete", "@DommandTransferOrder_ID", id);
            return true;
        }
        public bool UpdateTMCommandTransferOrdeStatusMem(clsTMCommandTransferOrderProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Id", data.DommandTransferOrder_ID);
            cls.AddParameter("@DommandTransferOrder_Status_Mem", data.DommandTransferOrder_Status_Mem);
            cls.ExecuteNonQuery("sp_Review_Update");
            return true;
        }
        public bool UpdateTMCommandTransferOrdeStatusLeadership(clsTMCommandTransferOrderProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@Id", data.DommandTransferOrder_ID);
            cls.AddParameter("@DommandTransferOrder_Leadership", data.DommandTransferOrder_Leadership);
            cls.ExecuteNonQuery("sp_Review_Update_LD");
            return true;
        }
        public bool TMCommandTransferOrder_Check_Delete_TMSalesReport(int id)
        {
            dt = cls.LayDuLieuParameter("sp_TMCommandTransferOrder_Check_Delete_TMSalesReport", "@Id", id);
            if (dt.Rows.Count > 0)
                return true;
            return false;
        }
        public bool TMCommandTransferOrder_Update_Stt(clsTMCommandTransferOrderProperty data)
        {
            cls.CreateNewSqlCommand();
            cls.AddParameter("@DommandTransferOrder_ID", data.DommandTransferOrder_ID);
            cls.ExecuteNonQuery("sp_TM_TMCommandTransferOrder_Update_Stt");
            return true;
        }
        #endregion

        #region[Search-Fillter]
        public DataTable TMCommandTransferOrde_Fillter_Date(string DateBegin, string EndBegin)
        {
            return cls.FillterDay("sp_TM_TMCommandTransferOrder_Fillter_Date", DateBegin, EndBegin);
        }
        public DataTable TMCommandTransferOrde_Fillter(string status)
        {
            return cls.LayDuLieuParameter1("TM_TMCommandTransferOrder_Fillter_Status", status);
        }
        public DataTable Search(string keywords)
        {
            return cls.Search("sp_TM_TMCommandTransferOrder_Search", "@KEYWORDS", keywords);
        }
        #endregion
    }
}
